﻿using System.Windows;
using Microsoft.Office.Interop.Word;

namespace Songhay.Office2010.Word
{
    /// <summary>
    /// Static members
    /// for <see cref="Microsoft.Office.Interop.Word.Application"/>
    /// and WPF PresentationCore.
    /// </summary>
    public static class WordApplicationUtility
    {
        /// <summary>
        /// Adds the Office Word key binding.
        /// </summary>
        /// <param name="word">The word.</param>
        /// <param name="category">The category.</param>
        /// <param name="command">The command.</param>
        /// <param name="key1">The key1.</param>
        /// <param name="key2">The key2.</param>
        /// <remarks>
        ///     For more detail, see “KeyBindings.Add Method”
        ///     (http://msdn.microsoft.com/en-us/library/bb237125%28office.12%29.aspx)
        /// </remarks>
        public static void AddKeyBinding(Application word,
            WdKeyCategory category, string command,
            int key1, object key2 = null,
            object commandParameter = null)
        {
            if(word == null) return;

            word.KeyBindings.Add(category, command, key1,
                key2.OrMissing(), commandParameter.OrMissing());
        }

        /// <summary>
        /// Clears the clipboard.
        /// </summary>
        public static void ClearClipboard()
        {
            Clipboard.SetDataObject(new DataObject(), true);
        }

        /// <summary>
        /// Copies to clipboard.
        /// </summary>
        /// <param name="textData">The text data.</param>
        public static void CopyToClipboard(string textData)
        {
            Clipboard.SetDataObject(new DataObject(textData), true);
        }

    }
}
